package com.glsx.web.security.controller;

import com.alibaba.dubbo.config.annotation.DubboConsumer;
import com.glsx.security.domain.LoginAccount;
import com.glsx.security.domain.enums.LoginAccountStatus;
import com.glsx.security.service.LoginAccountService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2016/11/10
 * \* Time: 11:07
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
@RestController
@RequestMapping("security")
public class SecurityController {
    @DubboConsumer(timeout = 20000)
    private LoginAccountService loginAccountService;
    @RequestMapping("{id}")
    public LoginAccount getLoginAccount(@PathVariable Integer id){
        return loginAccountService.findOne(id);
    }
    @RequestMapping("create")
    public LoginAccount createLoginAccount(){
        LoginAccount loginAccount = new LoginAccount();
        //loginAccount.setId(2);
        loginAccount.setLoginName("sunqian");
        loginAccount.setLoginPassword("12345678");
        loginAccount.setEmail("123@didihu.com.cn");
        loginAccount.setSalt("");
        loginAccount.setMobile("13800000000");
        loginAccount.setStatus(LoginAccountStatus.AUTHED);
        loginAccount.setRegisteredTime(new Date());
        System.out.println(loginAccount.toString());
        loginAccountService.save(loginAccount);
        return loginAccount;
    }
}
